package com.indusfo.spc.controller;

import com.indusfo.spc.aspect.SystemControllerLog;
import com.indusfo.spc.pojo.WarehouseMaterial;
import com.indusfo.spc.service.WarehouseMaterialService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 库位物料控制层
 */
@Controller
@RequestMapping("/warehouseMaterial")
public class WarehouseMaterialController {

    @Autowired
    private WarehouseMaterialService warehouseMaterialService;

    /**
     * 查询
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/queryWarehouseMaterial")
    @SystemControllerLog(description="查询")
    @ResponseBody
    public JSONObject queryWarehouseMaterial(WarehouseMaterial warehouseMaterial) {
        JSONObject json = warehouseMaterialService.selectWarehouseMaterial(warehouseMaterial);
        return json;
    }

    /**
     * 新增
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/insertWarehouseMaterial")
    @SystemControllerLog(description="新增")
    @ResponseBody
    public JSONObject insertWarehouseMaterial(WarehouseMaterial warehouseMaterial) {
        JSONObject json = warehouseMaterialService.insertWarehouseMaterial(warehouseMaterial);
        return json;
    }

    /**
     * 修改
     * @return
     */
    @RequestMapping(value = "/updateWarehouseMaterial")
    @SystemControllerLog(description="修改")
    @ResponseBody
    public JSONObject updateWarehouseMaterial(WarehouseMaterial warehouseMaterial){
        JSONObject json=warehouseMaterialService.updateWarehouseMaterial(warehouseMaterial);
        return json;
    }

    /**
     * 启用/停用/删除
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/definesWarehouseMaterial")
    @SystemControllerLog(description="启用/停用/删除")
    @ResponseBody
    public JSONObject definesWarehouseMaterial(Long[] warehouseMaterialIds, Integer dataState) {
        dataState = 2;
        JSONObject json = warehouseMaterialService.definesWarehouseMaterial(warehouseMaterialIds, dataState);
        return json;
    }

}
